﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace DotNETX.Utility.Text
{
    public static class StringValidateUtils
    {
        public static bool IsMatch(string input, string pattern)
        {
            return RegexpUtils.IsMatch(input, pattern);
        }

        /// <summary> 
        /// 只能输入数字：
        /// "^[0-9]*$"
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static bool OnlyDigital(string input)
        {
            return RegexpUtils.IsMatch(input, "^[0-9]*$");
        }

        /// <summary>
        /// 只能输入由26个英文字母组成的字符串：
        /// "^[A-Za-z]*$"
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static bool OnlyLetter(string input)
        {
            return RegexpUtils.IsMatch(input, "^[A-Za-z]*$");
        }
        
        /// <summary>
        /// 只能输入由26个大写英文字母组成的字符串：
        /// "^[A-Z]*$"
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static bool OnlyUpperCaseLetter(string input)
        {
            return RegexpUtils.IsMatch(input, "^[A-Z]*$");
        }

        /// <summary>
        /// 只能输入由26个小写英文字母组成的字符串：
        /// "^[a-z]*$"
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static bool OnlyLowerCaseLetter(string input)
        {
            return RegexpUtils.IsMatch(input, "^[a-z]*$");
        }

        /// <summary>
        /// 只能输入由数字、26个英文字母组成的字符串：
        /// "^[A-Za-z0-9]*$"
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static bool OnlyDigitalLetter(string input)
        {
            return RegexpUtils.IsMatch(input, @"^[A-Za-z0-9]*$");
        }

        /// <summary>
        /// 只能输入由数字、26个英文字母或者下划线组成的字符串：
        /// "^[A-Za-z0-9_]*$"
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static bool OnlyDigital_Letter(string input)
        {
            return RegexpUtils.IsMatch(input, @"^[A-Za-z0-9_]*$");
        }

        /// <summary>
        /// 只能输入汉字：
        /// "^[\u4e00-\u9fa5]*$"
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static bool OnlyChinese(string input)
        {
            return RegexpUtils.IsMatch(input, @"^[\u4e00-\u9fa5]*$");
        }

    }
}
